#set( $controllerActionsOLD = ["List", "Create", "New", "Edit", "Update", "Detail", "Delete", "Index", "Help", "*"])
#set( $controllerActions = ["*"])
#set( $securityRoles = ["SiteAdministrator", "Editor", "Member"])
#set( $nonEntitySecureControllers = ["FileManager", "AdManager"])
#set( $nonEntityPublicControllers = ["Home", "Go", "Get", "AdServer"])

/* Template $ThisTemplateName $Neo.Date by $Neo.User */
#foreach($entity in $Neo.Model.Entities)
#foreach($rel in $entity.ToOneRelationships)
IF EXISTS(SELECT * FROM dbo.sysobjects WHERE id = object_id(N'fk_${entity.TableName}_${rel.VarName}') AND OBJECTPROPERTY(id, N'IsConstraint') = 1)
	ALTER TABLE $entity.TableName DROP CONSTRAINT fk_${entity.TableName}_${rel.VarName};

#end
#end

#foreach($entity in $Neo.Model.Entities)
IF EXISTS(SELECT * FROM dbo.sysobjects WHERE id = object_id(N'$entity.TableName') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
	DROP TABLE $entity.TableName

#end

#foreach($entity in $Neo.Model.Entities)
CREATE TABLE $entity.TableName
(
#foreach($attribute in $entity.Attributes)
	$attribute.ColumnName $attribute.ColumnType#if($attribute.Size)($attribute.Size)#end#if($attribute.IsIdentityColumn && $entity.IdMethod.ToString == "Native") IDENTITY#end#if(!$attribute.AllowsNull) NOT NULL#end,
#end

	CONSTRAINT pk_$entity.TableName PRIMARY KEY ( #foreach($column in $entity.PkColumns)#if( $velocityCount > 1), #end$column.ColumnName#end )
);

#end

#foreach($entity in $Neo.Model.Entities)
#if($entity.ToOneRelationships.Count > 0)
#foreach($rel in $entity.ToOneRelationships)
ALTER TABLE $entity.TableName ADD CONSTRAINT fk_${entity.TableName}_${rel.VarName} FOREIGN KEY ( $rel.LocalKey ) REFERENCES $rel.ForeignEntity.TableName ( $rel.ForeignKey ); 
#end

#end
#end

#set ($useBuiltins = 0)
#foreach($entity in $Neo.Model.Entities)
#if ($entity.TableName.EndsWith("Security_RoleObjectPrivledgeLinks"))
#set ($useBuiltins = 1)
#end
#end

#if ($Neo.UseBuiltins)

SET identity_insert [Statuses] on

INSERT [Statuses] ([StatusID], [Name], [AppliesTo]) VALUES (1, 'Active', '*')
INSERT [Statuses] ([StatusID], [Name], [AppliesTo]) VALUES (2, 'Pending Approval', '*')
INSERT [Statuses] ([StatusID], [Name], [AppliesTo]) VALUES (3, 'Pending Verification', '*')
SET identity_insert [Statuses] off
GO

SET identity_insert [SecurityObjectType] on

INSERT [SecurityObjectType] ([SecurityObjectTypeID], [Name], [Controller], [ShowInMenu]) VALUES (1, 'undefined', 'undefined', 0)
INSERT [SecurityObjectType] ([SecurityObjectTypeID], [Name], [Controller], [ShowInMenu]) VALUES (2, 'Security', 'Security', 1)
INSERT [SecurityObjectType] ([SecurityObjectTypeID], [Name], [Controller], [ShowInMenu]) VALUES (3, 'Content', 'Content', 1)
INSERT [SecurityObjectType] ([SecurityObjectTypeID], [Name], [Controller], [ShowInMenu]) VALUES (4, 'Site', 'Site', 1)
INSERT [SecurityObjectType] ([SecurityObjectTypeID], [Name], [Controller], [ShowInMenu]) VALUES (5, 'Administration', 'Administration', 1)
INSERT [SecurityObjectType] ([SecurityObjectTypeID], [Name], [Controller], [ShowInMenu]) VALUES (6, 'Ad Manager', 'AdManager', 1)
INSERT [SecurityObjectType] ([SecurityObjectTypeID], [Name], [Controller], [ShowInMenu]) VALUES (7, 'Merchant', 'Merchant', 1)
SET identity_insert [SecurityObjectType] off
GO

SET identity_insert [BannerTypes] on

INSERT [BannerTypes] ([BannerTypeID], [Name]) VALUES (1, 'Text')
INSERT [BannerTypes] ([BannerTypeID], [Name]) VALUES (2, 'Image')
INSERT [BannerTypes] ([BannerTypeID], [Name]) VALUES (3, 'Flash')
SET identity_insert [BannerTypes] off
GO

SET identity_insert [PageTypes] on

INSERT [PageTypes] ([PageTypeID], [Name], [ViewName]) VALUES (1, 'Content', 'Index')
INSERT [PageTypes] ([PageTypeID], [Name], [ViewName]) VALUES (2, 'Chapter', 'Index')
SET identity_insert [PageTypes] off
GO

SET identity_insert [ContentMimeTypes] on

INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (1, '', 'application', 'octet-stream')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (2, '323', 'text', 'h323')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (3, 'acx', 'application', 'internet-property-stream')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (4, 'ai', 'application', 'postscript')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (5, 'aif', 'audio', 'x-aiff')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (6, 'aifc', 'audio', 'x-aiff')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (7, 'aiff', 'audio', 'x-aiff')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (8, 'asf', 'video', 'x-ms-asf')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (9, 'asr', 'video', 'x-ms-asf')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (10, 'asx', 'video', 'x-ms-asf')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (11, 'au', 'audio', 'basic')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (12, 'avi', 'video', 'x-msvideo')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (13, 'axs', 'application', 'olescript')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (14, 'bas', 'text', 'plain')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (15, 'bcpio', 'application', 'x-bcpio')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (16, 'bin', 'application', 'octet-stream')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (17, 'bmp', 'image', 'bmp')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (18, 'c', 'text', 'plain')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (19, 'cat', 'application', 'vnd.ms-pkiseccat')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (20, 'cdf', 'application', 'x-cdf')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (21, 'cer', 'application', 'x-x509-ca-cert')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (22, 'class', 'application', 'octet-stream')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (23, 'clp', 'application', 'x-msclip')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (24, 'cmx', 'image', 'x-cmx')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (25, 'cod', 'image', 'cis-cod')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (26, 'cpio', 'application', 'x-cpio')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (27, 'crd', 'application', 'x-mscardfile')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (28, 'crl', 'application', 'pkix-crl')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (29, 'crt', 'application', 'x-x509-ca-cert')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (30, 'csh', 'application', 'x-csh')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (31, 'css', 'text', 'css')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (32, 'dcr', 'application', 'x-director')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (33, 'der', 'application', 'x-x509-ca-cert')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (34, 'dir', 'application', 'x-director')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (35, 'dll', 'application', 'x-msdownload')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (36, 'dms', 'application', 'octet-stream')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (37, 'doc', 'application', 'msword')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (38, 'dot', 'application', 'msword')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (39, 'dvi', 'application', 'x-dvi')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (40, 'dxr', 'application', 'x-director')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (41, 'eps', 'application', 'postscript')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (42, 'etx', 'text', 'x-setext')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (43, 'evy', 'application', 'envoy')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (44, 'exe', 'application', 'octet-stream')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (45, 'fif', 'application', 'fractals')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (46, 'flr', 'x-world', 'x-vrml')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (47, 'gif', 'image', 'gif')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (48, 'gtar', 'application', 'x-gtar')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (49, 'gz', 'application', 'x-gzip')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (50, 'h', 'text', 'plain')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (51, 'hdf', 'application', 'x-hdf')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (52, 'hlp', 'application', 'winhlp')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (53, 'hqx', 'application', 'mac-binhex40')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (54, 'hta', 'application', 'hta')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (55, 'htc', 'text', 'x-component')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (56, 'htm', 'text', 'html')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (57, 'html', 'text', 'html')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (58, 'htt', 'text', 'webviewhtml')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (59, 'ico', 'image', 'x-icon')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (60, 'ief', 'image', 'ief')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (61, 'iii', 'application', 'x-iphone')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (62, 'ins', 'application', 'x-internet-signup')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (63, 'isp', 'application', 'x-internet-signup')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (64, 'jfif', 'image', 'pipeg')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (65, 'jpe', 'image', 'jpeg')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (66, 'jpeg', 'image', 'jpeg')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (67, 'jpg', 'image', 'jpeg')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (68, 'js', 'application', 'x-javascript')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (69, 'latex', 'application', 'x-latex')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (70, 'lha', 'application', 'octet-stream')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (71, 'lsf', 'video', 'x-la-asf')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (72, 'lsx', 'video', 'x-la-asf')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (73, 'lzh', 'application', 'octet-stream')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (74, 'm13', 'application', 'x-msmediaview')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (75, 'm14', 'application', 'x-msmediaview')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (76, 'm3u', 'audio', 'x-mpegurl')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (77, 'man', 'application', 'x-troff-man')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (78, 'mdb', 'application', 'x-msaccess')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (79, 'me', 'application', 'x-troff-me')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (80, 'mht', 'message', 'rfc822')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (81, 'mhtml', 'message', 'rfc822')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (82, 'mid', 'audio', 'mid')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (83, 'mny', 'application', 'x-msmoney')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (84, 'mov', 'video', 'quicktime')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (85, 'movie', 'video', 'x-sgi-movie')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (86, 'mp2', 'video', 'mpeg')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (87, 'mp3', 'audio', 'mpeg')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (88, 'mpa', 'video', 'mpeg')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (89, 'mpe', 'video', 'mpeg')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (90, 'mpeg', 'video', 'mpeg')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (91, 'mpg', 'video', 'mpeg')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (92, 'mpp', 'application', 'vnd.ms-project')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (93, 'mpv2', 'video', 'mpeg')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (94, 'ms', 'application', 'x-troff-ms')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (95, 'mvb', 'application', 'x-msmediaview')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (96, 'nws', 'message', 'rfc822')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (97, 'oda', 'application', 'oda')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (98, 'p10', 'application', 'pkcs10')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (99, 'p12', 'application', 'x-pkcs12')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (100, 'p7b', 'application', 'x-pkcs7-certificates')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (101, 'p7c', 'application', 'x-pkcs7-mime')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (102, 'p7m', 'application', 'x-pkcs7-mime')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (103, 'p7r', 'application', 'x-pkcs7-certreqresp')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (104, 'p7s', 'application', 'x-pkcs7-signature')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (105, 'pbm', 'image', 'x-portable-bitmap')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (106, 'pdf', 'application', 'pdf')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (107, 'pfx', 'application', 'x-pkcs12')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (108, 'pgm', 'image', 'x-portable-graymap')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (110, 'pko', 'application', 'ynd.ms-pkipko')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (111, 'pma', 'application', 'x-perfmon')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (112, 'pmc', 'application', 'x-perfmon')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (113, 'pml', 'application', 'x-perfmon')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (114, 'pmr', 'application', 'x-perfmon')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (115, 'pmw', 'application', 'x-perfmon')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (116, 'png', 'image', 'png')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (117, 'pnm', 'image', 'x-portable-anymap')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (118, 'pot,', 'application', 'vnd.ms-powerpoint')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (119, 'ppm', 'image', 'x-portable-pixmap')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (120, 'pps', 'application', 'vnd.ms-powerpoint')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (121, 'ppt', 'application', 'vnd.ms-powerpoint')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (122, 'prf', 'application', 'pics-rules')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (123, 'ps', 'application', 'postscript')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (124, 'pub', 'application', 'x-mspublisher')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (125, 'qt', 'video', 'quicktime')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (126, 'ra', 'audio', 'x-pn-realaudio')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (127, 'ram', 'audio', 'x-pn-realaudio')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (128, 'ras', 'image', 'x-cmu-raster')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (129, 'rgb', 'image', 'x-rgb')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (130, 'rm', 'application', 'vnd.rn-realmedia')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (131, 'rmi', 'audio', 'mid')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (132, 'roff', 'application', 'x-troff')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (133, 'rtf', 'application', 'rtf')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (134, 'rtx', 'text', 'richtext')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (135, 'scd', 'application', 'x-msschedule')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (136, 'sct', 'text', 'scriptlet')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (137, 'setpay', 'application', 'set-payment-initiation')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (138, 'setreg', 'application', 'set-registration-initiation')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (139, 'sh', 'application', 'x-sh')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (140, 'shar', 'application', 'x-shar')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (141, 'sit', 'application', 'x-stuffit')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (142, 'snd', 'audio', 'basic')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (143, 'spc', 'application', 'x-pkcs7-certificates')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (144, 'spl', 'application', 'futuresplash')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (145, 'src', 'application', 'x-wais-source')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (146, 'sst', 'application', 'vnd.ms-pkicertstore')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (147, 'stl', 'application', 'vnd.ms-pkistl')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (148, 'stm', 'text', 'html')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (149, 'sv4cpio', 'application', 'x-sv4cpio')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (150, 'sv4crc', 'application', 'x-sv4crc')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (151, 'svg', 'image', 'svg+xml')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (152, 'swf', 'application', 'x-shockwave-flash')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (153, 't', 'application', 'x-troff')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (154, 'tar', 'application', 'x-tar')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (155, 'tcl', 'application', 'x-tcl')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (156, 'tex', 'application', 'x-tex')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (157, 'texi', 'application', 'x-texinfo')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (158, 'texinfo', 'application', 'x-texinfo')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (159, 'tgz', 'application', 'x-compressed')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (160, 'tif', 'image', 'tiff')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (161, 'tiff', 'image', 'tiff')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (162, 'tr', 'application', 'x-troff')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (163, 'trm', 'application', 'x-msterminal')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (164, 'tsv', 'text', 'tab-separated-values')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (165, 'txt', 'text', 'plain')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (166, 'uls', 'text', 'iuls')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (167, 'ustar', 'application', 'x-ustar')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (168, 'vcf', 'text', 'x-vcard')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (169, 'vrml', 'x-world', 'x-vrml')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (170, 'wav', 'audio', 'x-wav')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (171, 'wcm', 'application', 'vnd.ms-works')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (172, 'wdb', 'application', 'vnd.ms-works')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (173, 'wks', 'application', 'vnd.ms-works')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (174, 'wm', 'video', 'x-ms-wm')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (175, 'wma', 'audio', 'x-ms-wma')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (176, 'wmf', 'application', 'x-msmetafile')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (177, 'wps', 'application', 'vnd.ms-works')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (178, 'wri', 'application', 'x-mswrite')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (179, 'wrl', 'x-world', 'x-vrml')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (180, 'wrz', 'x-world', 'x-vrml')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (181, 'xaf', 'x-world', 'x-vrml')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (182, 'xbm', 'image', 'x-xbitmap')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (183, 'xla', 'application', 'vnd.ms-excel')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (184, 'xlc', 'application', 'vnd.ms-excel')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (185, 'xlm', 'application', 'vnd.ms-excel')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (186, 'xls', 'application', 'vnd.ms-excel')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (187, 'xlt', 'application', 'vnd.ms-excel')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (188, 'xlw', 'application', 'vnd.ms-excel')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (189, 'xof', 'x-world', 'x-vrml')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (190, 'xpm', 'image', 'x-xpixmap')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (191, 'xpng', 'image', 'x-png')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (192, 'xwd', 'image', 'x-xwindowdump')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (193, 'z', 'application', 'x-compress')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (194, 'zip', 'application', 'zip')
INSERT [ContentMimeTypes] ([ContentMimeTypeID], [Extension], [Type], [SubType]) VALUES (195, 'jpg', 'image', 'pjpeg')
SET identity_insert [ContentMimeTypes] off
GO

SET identity_insert [GenericTypes] on

INSERT [GenericTypes] ([TypeID], [Name], [AppliesTo], [StatusID]) VALUES (1, 'Editor', 'Notes', 1)
INSERT [GenericTypes] ([TypeID], [Name], [AppliesTo], [StatusID]) VALUES (2, 'Footnote', 'Notes', 1)
SET identity_insert [GenericTypes] off
GO

insert into ${Neo.Model.TablePrefix}Security_Roles (RoleID, Name) values (NEWID(), 'Administrator');
insert into ${Neo.Model.TablePrefix}Security_Roles (RoleID, Name) values (NEWID(), 'SiteAdministrator');
insert into ${Neo.Model.TablePrefix}Security_Roles (RoleID, Name) values (NEWID(), 'Editor');
insert into ${Neo.Model.TablePrefix}Security_Roles (RoleID, Name) values (NEWID(), 'Member');
insert into ${Neo.Model.TablePrefix}Security_Roles (RoleID, Name) values (NEWID(), 'User');

insert into ${Neo.Model.TablePrefix}Security_Users (UserID, FirstName, LastName, Login, Password, DateCreated, StatusID, RoleID) select  NEWID(), '', '', 'admin', 'password', GetDate(), 1, ${Neo.Model.TablePrefix}Security_Roles.RoleID from ${Neo.Model.TablePrefix}Security_Roles where ${Neo.Model.TablePrefix}Security_Roles.Name = 'Administrator' ;
insert into ${Neo.Model.TablePrefix}Security_Users (UserID, FirstName, LastName, Login, Password, DateCreated, StatusID, RoleID) select NEWID(), '', '', 'Anonymous', '', GetDate(), 1, ${Neo.Model.TablePrefix}Security_Roles.RoleID from ${Neo.Model.TablePrefix}Security_Roles where ${Neo.Model.TablePrefix}Security_Roles.Name = 'User'  ;

insert into Security_Privledges (PrivledgeID, Name, ShowInMenu) values(NEWID(), 'List', 1);
insert into Security_Privledges (PrivledgeID, Name, ShowInMenu) values(NEWID(), 'Create', 1);
insert into Security_Privledges (PrivledgeID, Name, ShowInMenu) values(NEWID(), 'New', 1);
insert into Security_Privledges (PrivledgeID, Name, ShowInMenu) values(NEWID(), 'Edit', 1);
insert into Security_Privledges (PrivledgeID, Name, ShowInMenu) values(NEWID(), 'Update', 1);
insert into Security_Privledges (PrivledgeID, Name, ShowInMenu) values(NEWID(), 'Detail', 1);
insert into Security_Privledges (PrivledgeID, Name, ShowInMenu) values(NEWID(), 'Delete', 1);
insert into Security_Privledges (PrivledgeID, Name, ShowInMenu) values(NEWID(), 'Index', 1);
insert into Security_Privledges (PrivledgeID, Name, ShowInMenu) values(NEWID(), 'Help', 1);
insert into Security_Privledges (PrivledgeID, Name, ShowInMenu) values(NEWID(), '*', 1);

#foreach($entity in $Neo.Model.Entities)
insert into ${Neo.Model.TablePrefix}Security_Objects (ObjectID, Name, SecurityObjectTypeID) values (NEWID(), '${entity.ClassName}', 1);

insert into ${Neo.Model.TablePrefix}Security_RoleObjectLinks (ShowInMenu, RoleObjectID, RoleID, ObjectID)  select 1, NEWID(), ${Neo.Model.TablePrefix}Security_Roles.RoleID, ${Neo.Model.TablePrefix}Security_Objects.ObjectID from ${Neo.Model.TablePrefix}Security_Roles, ${Neo.Model.TablePrefix}Security_Objects where ${Neo.Model.TablePrefix}Security_Roles.Name = 'Administrator' and ${Neo.Model.TablePrefix}Security_Objects.Name = '${entity.ClassName}';

#foreach($action in $controllerActions)
insert into ${Neo.Model.TablePrefix}Security_RoleObjectPrivledgeLinks (RoleObjectPrivledgeID, RoleObjectID, PrivledgeID, Enabled) select NEWID(), ${Neo.Model.TablePrefix}Security_RoleObjectLinks.RoleObjectID, ${Neo.Model.TablePrefix}Security_Privledges.PrivledgeID, 1 from ${Neo.Model.TablePrefix}Security_Roles, ${Neo.Model.TablePrefix}Security_Objects, ${Neo.Model.TablePrefix}Security_RoleObjectLinks, ${Neo.Model.TablePrefix}Security_Privledges where ((${Neo.Model.TablePrefix}Security_RoleObjectLinks.RoleID = ${Neo.Model.TablePrefix}Security_Roles.RoleID and ${Neo.Model.TablePrefix}Security_Roles.Name = 'Administrator') and (${Neo.Model.TablePrefix}Security_RoleObjectLinks.ObjectID = ${Neo.Model.TablePrefix}Security_Objects.ObjectID and ${Neo.Model.TablePrefix}Security_Objects.Name = '${entity.ClassName}')) and ${Neo.Model.TablePrefix}Security_Privledges.Name = '${action}';
#end

#end

#foreach($entity in $Neo.Model.Entities)
#foreach($securityRole in $securityRoles)

insert into ${Neo.Model.TablePrefix}Security_RoleObjectLinks (ShowInMenu, RoleObjectID, RoleID, ObjectID)  select 0, NEWID(), ${Neo.Model.TablePrefix}Security_Roles.RoleID, ${Neo.Model.TablePrefix}Security_Objects.ObjectID from ${Neo.Model.TablePrefix}Security_Roles, ${Neo.Model.TablePrefix}Security_Objects where ${Neo.Model.TablePrefix}Security_Roles.Name = '${securityRole}' and ${Neo.Model.TablePrefix}Security_Objects.Name = '${entity.ClassName}';

insert into ${Neo.Model.TablePrefix}Security_RoleObjectPrivledgeLinks (RoleObjectPrivledgeID, RoleObjectID, PrivledgeID, Enabled) select NEWID(), ${Neo.Model.TablePrefix}Security_RoleObjectLinks.RoleObjectID, ${Neo.Model.TablePrefix}Security_Privledges.PrivledgeID, 1 from ${Neo.Model.TablePrefix}Security_Roles, ${Neo.Model.TablePrefix}Security_Objects, ${Neo.Model.TablePrefix}Security_RoleObjectLinks, ${Neo.Model.TablePrefix}Security_Privledges where ((${Neo.Model.TablePrefix}Security_RoleObjectLinks.RoleID = ${Neo.Model.TablePrefix}Security_Roles.RoleID and ${Neo.Model.TablePrefix}Security_Roles.Name = '${securityRole}') and (${Neo.Model.TablePrefix}Security_RoleObjectLinks.ObjectID = ${Neo.Model.TablePrefix}Security_Objects.ObjectID and ${Neo.Model.TablePrefix}Security_Objects.Name = '${entity.ClassName}')) and ${Neo.Model.TablePrefix}Security_Privledges.Name = 'Index';

#end
#end

#foreach($entity in $nonEntitySecureControllers)

insert into ${Neo.Model.TablePrefix}Security_Objects (ObjectID, Name, SecurityObjectTypeID) values (NEWID(), '${entity}', 1);

insert into ${Neo.Model.TablePrefix}Security_RoleObjectLinks (ShowInMenu, RoleObjectID, RoleID, ObjectID)  select 1, NEWID(), ${Neo.Model.TablePrefix}Security_Roles.RoleID, ${Neo.Model.TablePrefix}Security_Objects.ObjectID from ${Neo.Model.TablePrefix}Security_Roles, ${Neo.Model.TablePrefix}Security_Objects where ${Neo.Model.TablePrefix}Security_Roles.Name = 'Administrator' and ${Neo.Model.TablePrefix}Security_Objects.Name = '${entity}';

#foreach($action in $controllerActions)
insert into ${Neo.Model.TablePrefix}Security_RoleObjectPrivledgeLinks (RoleObjectPrivledgeID, RoleObjectID, PrivledgeID, Enabled) select NEWID(), ${Neo.Model.TablePrefix}Security_RoleObjectLinks.RoleObjectID, ${Neo.Model.TablePrefix}Security_Privledges.PrivledgeID, 1 from ${Neo.Model.TablePrefix}Security_Roles, ${Neo.Model.TablePrefix}Security_Objects, ${Neo.Model.TablePrefix}Security_RoleObjectLinks, ${Neo.Model.TablePrefix}Security_Privledges where ((${Neo.Model.TablePrefix}Security_RoleObjectLinks.RoleID = ${Neo.Model.TablePrefix}Security_Roles.RoleID and ${Neo.Model.TablePrefix}Security_Roles.Name = 'Administrator') and (${Neo.Model.TablePrefix}Security_RoleObjectLinks.ObjectID = ${Neo.Model.TablePrefix}Security_Objects.ObjectID and ${Neo.Model.TablePrefix}Security_Objects.Name = '${entity}')) and ${Neo.Model.TablePrefix}Security_Privledges.Name = '${action}';
#end

#foreach($securityRole in $securityRoles)
insert into ${Neo.Model.TablePrefix}Security_RoleObjectLinks (ShowInMenu, RoleObjectID, RoleID, ObjectID)  select 0, NEWID(), ${Neo.Model.TablePrefix}Security_Roles.RoleID, ${Neo.Model.TablePrefix}Security_Objects.ObjectID from ${Neo.Model.TablePrefix}Security_Roles, ${Neo.Model.TablePrefix}Security_Objects where ${Neo.Model.TablePrefix}Security_Roles.Name = '${securityRole}' and ${Neo.Model.TablePrefix}Security_Objects.Name = '${entity}';
insert into ${Neo.Model.TablePrefix}Security_RoleObjectPrivledgeLinks (RoleObjectPrivledgeID, RoleObjectID, PrivledgeID, Enabled) select NEWID(), ${Neo.Model.TablePrefix}Security_RoleObjectLinks.RoleObjectID, ${Neo.Model.TablePrefix}Security_Privledges.PrivledgeID, 1 from ${Neo.Model.TablePrefix}Security_Roles, ${Neo.Model.TablePrefix}Security_Objects, ${Neo.Model.TablePrefix}Security_RoleObjectLinks, ${Neo.Model.TablePrefix}Security_Privledges where ((${Neo.Model.TablePrefix}Security_RoleObjectLinks.RoleID = ${Neo.Model.TablePrefix}Security_Roles.RoleID and ${Neo.Model.TablePrefix}Security_Roles.Name = '${securityRole}') and (${Neo.Model.TablePrefix}Security_RoleObjectLinks.ObjectID = ${Neo.Model.TablePrefix}Security_Objects.ObjectID and ${Neo.Model.TablePrefix}Security_Objects.Name = '${entity}')) and ${Neo.Model.TablePrefix}Security_Privledges.Name = 'Index';
#end

#end

#foreach($entity in $nonEntityPublicControllers)

insert into ${Neo.Model.TablePrefix}Security_Objects (ObjectID, Name, SecurityObjectTypeID) values (NEWID(), '${entity}', 1);

insert into ${Neo.Model.TablePrefix}Security_RoleObjectLinks (ShowInMenu, RoleObjectID, RoleID, ObjectID)  select 0, NEWID(), ${Neo.Model.TablePrefix}Security_Roles.RoleID, ${Neo.Model.TablePrefix}Security_Objects.ObjectID from ${Neo.Model.TablePrefix}Security_Roles, ${Neo.Model.TablePrefix}Security_Objects where ${Neo.Model.TablePrefix}Security_Roles.Name = 'Administrator' and ${Neo.Model.TablePrefix}Security_Objects.Name = '${entity}';

#foreach($action in $controllerActions)
insert into ${Neo.Model.TablePrefix}Security_RoleObjectPrivledgeLinks (RoleObjectPrivledgeID, RoleObjectID, PrivledgeID, Enabled) select NEWID(), ${Neo.Model.TablePrefix}Security_RoleObjectLinks.RoleObjectID, ${Neo.Model.TablePrefix}Security_Privledges.PrivledgeID, 1 from ${Neo.Model.TablePrefix}Security_Roles, ${Neo.Model.TablePrefix}Security_Objects, ${Neo.Model.TablePrefix}Security_RoleObjectLinks, ${Neo.Model.TablePrefix}Security_Privledges where ((${Neo.Model.TablePrefix}Security_RoleObjectLinks.RoleID = ${Neo.Model.TablePrefix}Security_Roles.RoleID and ${Neo.Model.TablePrefix}Security_Roles.Name = 'Administrator') and (${Neo.Model.TablePrefix}Security_RoleObjectLinks.ObjectID = ${Neo.Model.TablePrefix}Security_Objects.ObjectID and ${Neo.Model.TablePrefix}Security_Objects.Name = '${entity}')) and ${Neo.Model.TablePrefix}Security_Privledges.Name = '${action}';
#end

#foreach($securityRole in $securityRoles)
insert into ${Neo.Model.TablePrefix}Security_RoleObjectLinks (ShowInMenu, RoleObjectID, RoleID, ObjectID)  select 0, NEWID(), ${Neo.Model.TablePrefix}Security_Roles.RoleID, ${Neo.Model.TablePrefix}Security_Objects.ObjectID from ${Neo.Model.TablePrefix}Security_Roles, ${Neo.Model.TablePrefix}Security_Objects where ${Neo.Model.TablePrefix}Security_Roles.Name = '${securityRole}' and ${Neo.Model.TablePrefix}Security_Objects.Name = '${entity}';
insert into ${Neo.Model.TablePrefix}Security_RoleObjectPrivledgeLinks (RoleObjectPrivledgeID, RoleObjectID, PrivledgeID, Enabled) select NEWID(), ${Neo.Model.TablePrefix}Security_RoleObjectLinks.RoleObjectID, ${Neo.Model.TablePrefix}Security_Privledges.PrivledgeID, 1 from ${Neo.Model.TablePrefix}Security_Roles, ${Neo.Model.TablePrefix}Security_Objects, ${Neo.Model.TablePrefix}Security_RoleObjectLinks, ${Neo.Model.TablePrefix}Security_Privledges where ((${Neo.Model.TablePrefix}Security_RoleObjectLinks.RoleID = ${Neo.Model.TablePrefix}Security_Roles.RoleID and ${Neo.Model.TablePrefix}Security_Roles.Name = '${securityRole}') and (${Neo.Model.TablePrefix}Security_RoleObjectLinks.ObjectID = ${Neo.Model.TablePrefix}Security_Objects.ObjectID and ${Neo.Model.TablePrefix}Security_Objects.Name = '${entity}')) and ${Neo.Model.TablePrefix}Security_Privledges.Name = '*';
#end

#end

#end